<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    .cls {
      width: 300px;
      height: 200px;
      border: 2px solid red;
    }
  </style>
</head>

<body>
  <div id="app">
    <input type="text" v-model="firstName"><br>
    <input type="text" v-model="lastName"><br>
    <div class="cls">{{fullName}}</div>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    const vm = new Vue({
      "el": "#app",
      "data": {
        "firstName": "cz",
        "lastName": "cheng",
        "fullName": "cz cheng",
        "form1": {
          relation_key: "",
          bushi: ""
        }
      },
      "methods": {},
      "directives": {

      },
      "computed": {

      },
      "watch": { //监听器的使用
        /*  
          对于异步或开销比较大，使用监听器
        */
        firstName(val) {
          this.fullName = `${val}${this.lastName}`;
        },
        lastName(val) {
          this.fullName = this.firstName + `${val}`;
        },
        // 监听对象里面的属性值的改变
        "form1.relation_key": function relation_key() { }
      }
    });
  </script>
</body>

</html>